﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace www.coursera.algo.org.ProblemQuestion._5
{
    class Program
    {
        static void Main(string[] args)
        {
            string txtNumbers = "231552,234756,596873,648219,726312,981237,988331,1277361,1283379";
            string[] numbers = txtNumbers.Split(',');

            string fileName = "HashInt.txt";

            Dictionary<int,int> integerList = new Dictionary<int, int>();

            #region intitlize graph

            char[] delimiterChars = { ' ', ',', '.', ':', '\t' };

            int count = 1;
            using (StreamReader sr = new StreamReader("TestCases\\" + fileName))
            {
                String line;
                // Read and display lines from the file until the end of
                // the file is reached.
                while ((line = sr.ReadLine()) != null)
                {
                    int lineNumber = Convert.ToInt32(line);
                    if(!integerList.ContainsKey(lineNumber))
                        integerList.Add(lineNumber, count);
                    count = count + 1;
                }

            }

            #endregion


            int x, y;
            for (int i = 0; i < numbers.Length; i++)
            {
                x = Convert.ToInt32(numbers[i]);
                bool hasSum = false;
                foreach (KeyValuePair<int, int> integer in integerList)
                {
                    y = x - integer.Key;
                    if (integerList.ContainsKey(y) && integerList[y]!=integer.Value)
                    {
                        hasSum = true;
                        break;
                    }
                    

                }
                if (hasSum)
                {
                    Console.Write("1");
                }
                else
                {
                    Console.Write("0");
                }
                  
            }

            Console.ReadLine();
        }
    }
}
